package com.briup.service.impl;

import com.briup.bean.Book;
import com.briup.dao.BookMapper;
import com.briup.service.IBookService;
import com.briup.util.MyBatisSqlSessionFactory;

import java.util.List;

public class IBookServiceImpl implements IBookService {
    private BookMapper bookMapper;

    {
        bookMapper = MyBatisSqlSessionFactory.openSession().getMapper(BookMapper.class);
    }

    //查询所有书籍信息
    @Override
    public List<Book> findAllBooks() {
        return bookMapper.findAllBooks();
    }

    //通过书籍ID查询书籍信息
    @Override
    public Book findBookById(Integer id) {
        return bookMapper.findBookById(id);
    }

    @Override
    public List<Book> findBookByCategoryId(Integer categoryId) {
        return bookMapper.findBookByCategoryId(categoryId);
    }
}